﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Security.Cryptography;
using System.Web.Security;

namespace AidBrella.BLL
{
    public class Common:BaseModel
    {
        public string GetProjectSectorName(int? sectorId)
        {
            return _entities.ProjectSectorSet.Where(o => o.Id == sectorId).FirstOrDefault().Name;
        }

        public static string CreateSalt()
        {
            RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
            byte[] buff = new byte[32];
            rng.GetBytes(buff);

            return Convert.ToBase64String(buff);
        }

        public static string CreatePasswordHash(string pwd, string salt)
        {
            string saltAndPwd = String.Concat(pwd, salt);
            return FormsAuthentication.HashPasswordForStoringInConfigFile(saltAndPwd, "sha1");           
        }

        //public int GetLogedInUserId(string userName)
        //{
        //      UserModel _userModel = new UserModel();

        //   return 1;//  _userModel.GetUser(userName).u
        //}

    }
}
